﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:engine="clr-namespace:WPFLocalizeExtension.Engine;assembly=WPFLocalizeExtension" 
        xmlns:lex="clr-namespace:WPFLocalizeExtension.Extensions;assembly=WPFLocalizeExtension"
        xmlns:wnd="clr-namespace:UI.Windows"
        xmlns:adock="http://schemas.xceed.com/wpf/xaml/avalondock" 
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:controls="clr-namespace:UI.Resources.Controls"
        xmlns:converters="clr-namespace:UI.Resources.Converters" x:Class="UI.Windows.MainWindow"
        engine:LocalizeDictionary.DesignCulture="en"
        x:Name="This"
		Height="350" Width="525" Loaded="ThisWindowLoaded" WindowState="Maximized" Icon="/RAE;component/Resources/Icons/RAE.ico" Closing="WindowClosing">

	<Window.Resources>
		<converters:ProjectToTitleConverter x:Key="ProjectToTitleConverter"/>
		<TextBlock x:Key="SubstitutionTextBlock" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{lex:Loc RAE:Strings:TEXT_Open_project}"/>
	</Window.Resources>
	
	<Window.Title>
		<Binding Converter="{StaticResource ProjectToTitleConverter}" ElementName="This" Path="AppCore.DependencyContainer.Project"/>
	</Window.Title>

	<Window.CommandBindings>
		<CommandBinding Command="ApplicationCommands.New" Executed="NewCommandExecuted"/>
		<CommandBinding Command="ApplicationCommands.Open" Executed="OpenCommandExecuted"/>
		<CommandBinding Command="ApplicationCommands.Save" Executed="SaveCommandExecuted" CanExecute="SaveCommandCanExecuted"/>
		<CommandBinding Command="ApplicationCommands.SaveAs" Executed="SaveAsCommandExecuted" CanExecute="NotNullProjectRequirementCommandCanExecuted"/>
		<CommandBinding Command="ApplicationCommands.Close" Executed="CloseCommandExecuted" CanExecute="NotNullProjectRequirementCommandCanExecuted"/>
		<CommandBinding Command="wnd:MainWindow.AddResearchCommand" Executed="AddResearchCommandExecuted" CanExecute="NotNullProjectRequirementCommandCanExecuted"/>
		<CommandBinding Command="wnd:MainWindow.RemoveCurrentResearchCommand" Executed="RemoveResearchCommandExecuted" CanExecute="NotNullResearchRequirementCommandCanExecuted"/>
		<CommandBinding Command="wnd:MainWindow.ShowOptionsCommand" Executed="ShowOptionsCommandExecuted"/>
		<CommandBinding Command="wnd:MainWindow.ShowImportExportOptionsDialogCommand" Executed="ShowImportExportOptionsDialogCommandExecuted"/>
		<CommandBinding Command="wnd:MainWindow.ResetToDefaultOptionsCommand" Executed="ResetToDefaultOptionsCommandExecuted" CanExecute="ResetToDefaultOptionsCommandCanExecuted"/>
		<CommandBinding Command="wnd:MainWindow.ExportToPdfCommand" Executed="ExportToPdfCommandExecuted"  CanExecute="NotNullResearchRequirementCommandCanExecuted"/>
	</Window.CommandBindings>

	<Window.InputBindings>
		<KeyBinding Key="N" Modifiers="Control" Command="ApplicationCommands.New" />
		<KeyBinding Key="O" Modifiers="Control" Command="ApplicationCommands.Open" />
		<KeyBinding Key="S" Modifiers="Control" Command="ApplicationCommands.Save" />
	</Window.InputBindings>

	<DockPanel>
		<ToolBar DockPanel.Dock="Top">
			<Menu>
				<MenuItem Header="{lex:Loc RAE:Strings:Project}">
					<MenuItem Header="{lex:Loc RAE:Strings:New}" Command="ApplicationCommands.New" />
					<MenuItem Header="{lex:Loc RAE:Strings:Open}" Command="ApplicationCommands.Open" />
					<MenuItem Header="{lex:Loc RAE:Strings:Save}" Command="ApplicationCommands.Save"/>
					<MenuItem Header="{lex:Loc RAE:Strings:Save_as}" Command="ApplicationCommands.SaveAs"/>
					<MenuItem Header="{lex:Loc RAE:Strings:Close}" Command="ApplicationCommands.Close"/>
				</MenuItem>
				<MenuItem Header="{lex:Loc RAE:Strings:Research}">
					<MenuItem Header="{lex:Loc RAE:Strings:Add}" Command="wnd:MainWindow.AddResearchCommand" />
					<MenuItem Header="{lex:Loc RAE:Strings:Remove_current}" Command="wnd:MainWindow.RemoveCurrentResearchCommand" />
					<Separator />
					<MenuItem Header="{lex:Loc RAE:Strings:Export_to_PDF}" Command="wnd:MainWindow.ExportToPdfCommand" />
				</MenuItem>
				<MenuItem Header="{lex:Loc RAE:Strings:Options}">
					<MenuItem Header="{lex:Loc RAE:Strings:Options}" Command="wnd:MainWindow.ShowOptionsCommand"/>
					<Separator />
					<MenuItem Header="{lex:Loc RAE:Strings:Import_export}" Command="wnd:MainWindow.ShowImportExportOptionsDialogCommand" />
					<MenuItem Header="{lex:Loc RAE:Strings:Reset_to_defaults}" Command="wnd:MainWindow.ResetToDefaultOptionsCommand"/>
				</MenuItem>
			</Menu>
		</ToolBar>
		<adock:DockingManager AllowMixedOrientation="True" DataContext="{Binding AppCore.DependencyContainer.Project, ElementName=This}">
			<adock:LayoutRoot>
				<adock:LayoutRoot.LeftSide>
					<adock:LayoutAnchorSide>
						<adock:LayoutAnchorGroup>
							<adock:LayoutAnchorable x:Name="ResearchArea" Title="{lex:Loc RAE:Strings:Researches}" AutoHideMinWidth="350" FloatingWidth="400" FloatingHeight="300">
								<ListBox x:Name="ResearchesListBox" MinWidth="300" ItemsSource="{Binding Researches}" SelectionMode="Single" SelectedItem="{Binding CurrentResearch}"/>
							</adock:LayoutAnchorable>
						</adock:LayoutAnchorGroup>
						<adock:LayoutAnchorGroup>
							<adock:LayoutAnchorable x:Name="InformationArea" Title="{lex:Loc RAE:Strings:Information}" AutoHideMinWidth="350" FloatingWidth="400" FloatingHeight="300">
								<xctk:PropertyGrid x:Name="InformationPropertyGrid" ShowSearchBox="False" ShowSortOptions="False" NameColumnWidth="125" SelectedObject="{Binding CurrentResearch}" AutoGenerateProperties="False">
									<xctk:PropertyGrid.PropertyDefinitions>
										<xctk:PropertyDefinition Name="Name" />
										<xctk:PropertyDefinition Name="Description" />
										<xctk:PropertyDefinition Name="Date" />
										<xctk:PropertyDefinition Name="CustomInformation" />
									</xctk:PropertyGrid.PropertyDefinitions>
								</xctk:PropertyGrid>
							</adock:LayoutAnchorable>
						</adock:LayoutAnchorGroup>
					</adock:LayoutAnchorSide>
				</adock:LayoutRoot.LeftSide>
				<adock:LayoutPanel Orientation="Horizontal">
					<adock:LayoutDocumentPaneGroup>
						<adock:LayoutDocumentPane>
							<adock:LayoutDocument Title="{lex:Loc RAE:Strings:Cases}" CanClose="False" CanFloat="False">
								<controls:SubstitutableDataGrid x:Name="CasesSubstitutableDataGrid" SubstitutionTemplate="{StaticResource SubstitutionTextBlock}" Research="{Binding CurrentResearch, Mode=TwoWay}"/>
							</adock:LayoutDocument>
						</adock:LayoutDocumentPane>
					</adock:LayoutDocumentPaneGroup>
				</adock:LayoutPanel>
			</adock:LayoutRoot>
		</adock:DockingManager>
	</DockPanel>
</Window>